/**
 * 
 */
package pacMan;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Ellipse2D;

/**
 * 
 * Class: Pellet
 * Subclass of SuperpositionedStationaryObject; this is one of the ConsumableObjects that
 * the player collects to earn points.
 *
 * @author 		Tomas Rivera
 * @version 	$Id$
 * 
 */
public class Pellet extends SuperpositionedStationaryObject {

	//////////////////////////////////////////////////////////
	// Constructor methods
	//////////////////////////////////////////////////////////
	
	/**
	 * Creates a Pellet object with the specified point value.
	 * 
	 * @param w
	 * @param pValue
	 * @param objectLocationTracker
	 */
	public Pellet(WindowParameters w, int pValue, ObjectLocationTracker objectLocationTracker) {
		super(w, pValue, objectLocationTracker);
		diameter = w.getPixelScale() * 1 / 3;
	}
	
	//////////////////////////////////////////////////////////
	// Overridden methods
	//////////////////////////////////////////////////////////
	
	/*
	 * (non-Javadoc)
	 * @see pacMan.SuperpositionedStationaryObject#consumeObject(pacMan.Actor)
	 */
	@Override
	public void consumeObject(Actor consumer) {
		super.consumeObject(consumer);
		consumer.setFrozen(1);
	}

	/*
	 * (non-Javadoc)
	 * @see pacMan.SuperpositionedStationaryObject#drawSuperpositionedObject(java.awt.Graphics2D, pacMan.WindowParameters, int, int)
	 */
	@Override
	public void drawSuperpositionedObject(Graphics2D d, WindowParameters w, int xGrid, int yGrid) {
		Ellipse2D.Double circle = new Ellipse2D.Double(
				(double)((xGrid * w.getPixelScale()) + w.getPixelOffsetX() - (diameter / 2)), 
				(double)((yGrid * w.getPixelScale()) + w.getPixelOffsetY() - (diameter / 2)),
				diameter, diameter);
		d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		d.setColor(Color.WHITE);
		d.fill(circle);
		//System.out.printf("Drawing pellet at x=%d y=%d%n", xGrid, yGrid);
	}
	
	/*
	 * (non-Javadoc)
	 * @see pacMan.BasicDrawableObject#resizeObject()
	 */
	@Override
	public void resizeObject() {
		diameter = getWindowParams().getPixelScale() * 1 / 3;
	}
	
	//////////////////////////////////////////////////////////
	// Protected member variables
	//////////////////////////////////////////////////////////
	
	protected int diameter;
}
